<?php include $this->getViewFile('/common/Head'); ?>
<body class="J_scroll_fixed">
<style>
.product_img img {
    border:solid 3px #fff;
    margin-right:5px;
}
.product_img img.hover {
    border-color:#ff8800;
}
.product_img img.current {
    border-color:#df0001;
}
</style>
<div class="wrap J_check_wrap">
  <?php include $this->getViewFile('/common/Nav') ?>
  <form class="J_ajaxForm" action="<?php echo AdminBase::U("editor") ?>" method="post" id="myform">
    <div class="h_a">基本属性</div>
    <div class="table_full">
      <table width="100%" class="table_form contentWrap">
        <tbody>
          <tr>
            <th width="80">URL/ID</th>
            <td><input type="test" name="detail_url" class="input length_6" id="detail_url" value="<?php echo $data->detail_url ?>">
              <button class="btn J_ajax_getiteminfo" data-product_id="<?php echo $data->product_id ?>">获取最新信息</button>
              <input type="reset" class="button" value="重置"></td>
          </tr>
          <tr>
            <th>商品ID</th>
            <td><em id="product_id"><?php echo $data->product_id ?></em>
              <input type="hidden" name="product_id" value="<?php echo $data->product_id ?>"></td>
          </tr>
          <tr>
            <th>当前状态</th>
            <td><span class="gray"> <?php echo GoodsBmModel::model()->getHtmlStatus($data); ?> </span></td>
          </tr>
          <tr>
            <th >标签：</th>
            <td><?php include $this->getViewFile('/goods/tagInput') ?></td>
          </tr>
          <tr>
            <th>商品标题</th>
            <td><input type="text" name="goods_name" value="<?php echo $data->goods_name ?>" class="input length_6" id="goods_name"></td>
          </tr>
          <tr>
            <th>商品分类</th>
            <td><select name="cat_id">
                <option value="0">请选择商品分类</option>
                <?php echo CategoryModel::model()->htmlCategorySelectOption($data->cat_id) ?>
              </select></td>
          </tr>
          <tr>
            <th>商品原价</th>
            <td><span style="color:#00F" id="p_price"><?php echo $data->p_price; ?></span>
              <input type="hidden" name="p_price" value="<?php echo $data->p_price; ?>"></td>
          </tr>
          <tr>
            <th>活动价格</th>
            <td><input type="text" name="promo_price" class="input length_1" value="<?php echo  number_format($data->promo_price,2)?>" id="promo_price"></td>
          </tr>
          <tr>
            <th>销量
              </td>
            <td><input type="text" name="sales" class="input length_1" value="<?php echo  $data->sales?>" id="sales"></td>
          </tr>
          <tr>
            <th>卖家包邮
              </td>
            <td><?php echo Form::radio(array(1=>'免运费',0=>'不免运费'),$data->freeshipping,'name="freeshipping"'); ?></td>
          </tr>
          <tr>
            <th>报名数量
              </td>
            <td><input type="text" name="stock" class="input length_1" value="<?php echo  (int)$data->stock?>">
              <span class="gray">件</span></td>
          </tr>
          <tr>
            <th>上架时间
              </td>
            <td><input type="text" name="start_time" class="input length_2 J_datetime " value="<?php echo  date('Y-m-d H:i',$data->start_time)?>" placeholder="上架时间"></td>
          </tr>
          <tr>
            <th>下架时间
              </td>
            <td><input type="text" name="end_time" class="input length_2 J_datetime " value="<?php echo  date('Y-m-d H:i',$data->end_time)?>" placeholder="下架时间"></td>
          </tr>
          <tr>
            <th>所在地
              </td>
            <td><span class="state"><?php echo $data->state?></span> <span class="city"><?php echo $data->city?></span></td>
          </tr>
          <tr>
            <th>商品图片
              </td>
            <td><input type="text" name="product_img" value="<?php echo $data->product_img ?>" class="input" id="product_img" style="width:500px"></td>
          </tr>
          <tr>
            <th></td>
            <td><div class="product_img"> <img class="current" width="160" height="160" src="<?php echo $data->product_img ?>"> </div></td>
          </tr>
          <tr>
            <th>推荐理由
              </td>
            <td><textarea type="text" name="goods_brief" cols="60" rows="6"><?php echo $data->goods_brief?></textarea></td>
          </tr>
          <tr>
            <th>扩展属性
              </td>
            <td>
             <input type="hidden" value="0" name="is_best">
             <input type="hidden" value="0" name="is_new">
             <input type="hidden" value="0" name="is_hot">
             <input type="hidden" value="0" name="is_format">
             <input type="checkbox" name="is_best" <?php echo $data->is_best?'checked':'' ?> value="1">
              推荐
              <input type="checkbox" name="is_new" <?php echo $data->is_new?'checked':'' ?> value="1">
              新品
              <input type="checkbox" name="is_hot" <?php echo $data->is_hot?'checked':'' ?> value="1">
              热卖
              <input type="checkbox" name="is_format" <?php echo $data->is_format?'checked':'' ?> value="1"> 
              多规格</td>
          </tr>
          <tr>
            <th>Level
              </td>
            <td><?php echo Form::select(array(0=>'普通商品',1=>'在首页显示',2=>'秒杀商品'),$data->level,'name="level"'); ?></td>
          </tr>
          <tr>
            <th>商品排序
              </td>
            <td><input type="text" name="listorder" class="input length_1" value="<?php echo  (int)$data->listorder?>"></td>
          </tr>
          <?php if($data->status == 3){  ?>
          <tr>
            <th>邮寄样品状态</th>
            <td><?php  echo Form::radio(GoodsBmModel::getHtmlDelivery(),$data->isdelivery,'name="isdelivery"');  ?></td>
          </tr>
          <?php }  ?>

          <tr>
            <th>审核结果
              </td>
            <td><?php 
		  $statusTags = GoodsBmModel::model()->getStatusTags();
		  if($data->status != 4){
			  unset($statusTags[4]);
		  }
		  echo Form::radio($statusTags,$data->status,'name="status"'); 
		  ?><label><input name="is_show_wangwang" type="checkbox" value="1" <?php echo $data->is_show_wangwang?'checked':'' ?> /><font color="#0000FF">显示旺旺</font></label></td>
          </tr>
          <tr>
            <th>审核操作原因
              </td>
            <td><textarea type="text" name="note" cols="60" rows="3"><?php echo $data->note ?></textarea></td>
          </tr>
        </tbody>
      </table>
    </div>
    <div class="btn_wrap">
      <div class="btn_wrap_pd">
        <input type="hidden" name="goods_id" value="<?php echo $data->goods_id ?>">
        <input type="hidden" name="nick" value="<?php echo $data->nick ?>">
        <input type="hidden" name="item_type" value="<?php echo $data->item_type ?>">
        <button class="btn btn_submit mr10 J_ajax_submit_btn" type="submit">确认修改</button>
      </div>
    </div>
  </form>
</div>
<script src="<?php echo $staticUrl; ?>statics/js/common.js"></script> 
<script>
function product_img(){
	$('div.product_img img').click(function() {
		$('div.product_img img').removeClass('current');
		$(this).addClass('current');
		$('#product_img').val(this.src);
    });
}
$(function(){
	//点击图片
	if($('div.product_img img').length){
		product_img();
	}
	if($('button.J_ajax_getiteminfo').length){
		$('button.J_ajax_getiteminfo').click(function(){
			var but = this;
			var text = $(but).text();
			//var product_id = $(this).data('product_id');
			var product_id = $('input[name="detail_url"]').val();
			$(but).text('获取中...');
			$.getJSON('<?php echo AdminBase::U("public_iteminfo") ?>',{product_id:product_id},function(data){
				$(but).text(text);
				if(data.status){
					//商品地址
					$('#detail_url').val(data.detail_url);
					$('#goods_name').val(data.title);
					//原价
					$('#p_price').html(data.p_price);
					$('input[name="p_price"]').val(data.p_price);
					//活动价格
					$('#promo_price').val(data.promo_price);
					//商品ID
					$('#product_id').html(data.product_id);
					$('input[name="product_id"]').val(data.product_id);
					//旺旺
					$('input[name="nick"]').val(data.nick);
					//店铺类型
					$('input[name="item_type"]').val(data.item_type);
					//销量
					if(data.item_type==0){
						$('#sales').val(data.sales);
					}
					//$('.detail_url').val(data.detail_url);
					//图片
					var imgstr = '';
					if (data.images) {
						$.each(data.images,function(i,v){
							if(i == 0){
								$('#product_img').val(v);
								imgstr += '<img class="current" width="160" height="160" src=' + v + ' />';
							}else{
								 imgstr += '<img  width="160" height="160"  src=' + v + ' />';
							}
						});
						$('div.product_img').html(imgstr);
						product_img();
					}
				}
			});
			return false;
		});
	}
});
</script>
</body>
</html>